/**
 * 七牛云上传(暂时先用PHP上传)
 */
$(function(){
    let config = {
        region: 'qiniu.region.z0'
    };
    let putExtra = {
        fname: "",
        params: {},
        mimeType: null
    };

    if ( $("#fileList").length > 0 ) {
        /**
         *  图片上传模块
         *  @author zx
         *  @date 2019-12-19
         **/
        let $list = $("#fileList"),
            state = "pending",
            pathInput = $('#filePicker').next();

        $("#filePicker").click(function(){
            token('imageUploader');
        });

        var imageUploader = (uptoken) => {

        }

    }

    if ( $("#fileListAudio").length > 0 ) {
        /**
         *  音频上传模块
         *  @author zx
         *  @date 2019-12-20
         **/
        let $listAudio = $("#fileListAudio"),
            stateAudio = "pending",
            pathInputAudio = $('#filePickerAudio').next();

    }

    if ( $("#fileListAudio1").length > 0 ) {
        /**
         *  音频上传模块(1)
         *  @author zx
         *  @date 2019-12-20
         **/
        let $listAudio1 = $("#fileListAudio1"),
            stateAudio1 = "pending",
            pathInputAudio1 = $('#filePickerAudio1').next();

    }

    //eval(action+'('+res.data.token+')')
    let token = (action) => {
        $.ajax({
            url:'/admin/common/qiniuToken',
            success:(res) => eval(action+'("'+res.data.token+'")'),
            error:(XmlHttpRequest, textStatus, errorThrown) => {
                let errstr = XmlHttpRequest.responseText;
                if ( errstr ) {
                    layer.msg($.parseJSON(errstr).message,{icon:5,time:1000});
                } else {
                    layer.msg('服务错误!TOKEN获取失败',{icon:5,time:1000});
                }
            }
        })
    }

})
